import 'package:equatable/equatable.dart';

const kYookassaApiPaymentMetadataPurchaseItemSkuKey = 'purchase_item_sku';
const kYookassaApiPaymentMetadataUserIdKey = 'user_id';
const kYookassaApiPaymentMetadataSavedPaymentMethodIdKey = 'saved_payment_method_id';

class YookassaApiPaymentMetadataDto extends Equatable {
  const YookassaApiPaymentMetadataDto({
    required this.purchaseItemSku,
    required this.userId,
    required this.savedPaymentMethodId,
  });

  final String purchaseItemSku;
  final String userId;
  final String? savedPaymentMethodId;

  @override
  List<Object?> get props {
    return [
      purchaseItemSku,
      userId,
      savedPaymentMethodId,
    ];
  }

  factory YookassaApiPaymentMetadataDto.fromJson(Map<String, dynamic> json) {
    return YookassaApiPaymentMetadataDto(
      purchaseItemSku: json[kYookassaApiPaymentMetadataPurchaseItemSkuKey],
      userId: json[kYookassaApiPaymentMetadataUserIdKey],
      savedPaymentMethodId: json[kYookassaApiPaymentMetadataSavedPaymentMethodIdKey],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      kYookassaApiPaymentMetadataPurchaseItemSkuKey: purchaseItemSku,
      kYookassaApiPaymentMetadataUserIdKey: userId,
      kYookassaApiPaymentMetadataSavedPaymentMethodIdKey: savedPaymentMethodId,
    };
  }
}
